package process

import (
	"chat/client/utils"
	message "chat/common"
	"encoding/json"
	"fmt"
)

type SmsProcess struct{}

func (that *SmsProcess) SendGroupMes(content string) (err error) {
	var mes message.Message
	mes.Type = message.SmsMesType
	var smsMes message.SmsMes
	smsMes.UserId = CurUser.UserId
	smsMes.UserName = CurUser.UserName
	smsMes.Content = content
	data, err := json.Marshal(smsMes)
	if err != nil {
		return
	}
	mes.Data = string(data)
	data, err = json.Marshal(mes)
	if err != nil {
		return
	}
	tf := &utils.Transfer{
		Conn: CurUser.Conn,
	}
	err = tf.WritePkg(data)
	if err != nil {
		fmt.Println("消息发送失败，err=", err)
		return
	}
	return
}

func getSmsMes(smsMes message.SmsMes) {
	fmt.Printf("用户 %v：%v\n", smsMes.UserName, smsMes.Content)
}
